<cfif isdefined("FORM.search")>
	<cfset filter = "(&(!(OU=Archived_Users))(mDBStorageQuota=*)(mail=*)" />
	<cfif isdefined("FORM.first")>
		<cfset filter = filter & '(givenName=' & FORM.first & '*)' />  
	</cfif>
	<cfif isdefined("FORM.last")>
		<cfset filter = filter & '(sn=' & FORM.last & '*)' />  
	</cfif>
	<cfif isdefined("FORM.title")>
		<cfset filter = filter & '(title=' & FORM.title & '*)' />  
	</cfif>
	<cfif isdefined("FORM.department")>
		<cfset filter = filter & '(department=' & FORM.department & '*)' />  
	</cfif>
	<cfset filter = filter & ')' />

	<cfldap action="QUERY" name="ldapUsers"
		attributes="cn,givenName,sn,telephoneNumber,department,title,userPrincipalName"
		start="OU=SCFUsers,dc=SouthcentralFoundation,dc=com"
		server="10.100.1.9"
		filter="#filter#"
		sort="displayName"
		username="scf\Userlist"
		password="DefinedMan" />
</cfif>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Mailbox Tool</title>
		<link href="/scfApps/css/scfAppsGeneral.css" rel="stylesheet" type="text/css" />
		<link href="/scfApps/css/scfApps.css" rel="stylesheet" type="text/css" />
		<link href="/scfApps/css/scfAppsBlue.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="/scfApps/scfApps.js"></script>
		<style type="text/css">
			div#sideBarLeft { width: 280px; }
			div#outer { width: 90%; }
			td { vertical-align: top; }
		</style>
	</head>
	<body onLoad="document.getElementById('last').focus()">
		<div id="outer">
			<div id="header">
				<h1><span class="headerColor">SCF</span> Mailbox Administration Tool</h1>
	        	<h2><cfoutput>#APPLICATION.PROGRAM_VERSION#</cfoutput></h2>
			</div>
			
			<div id="sideBarLeft">
				<h2>Search For Users</h2>
				<cfform name="search" preserveData="yes">
					<table>
						<tr>
							<th>Last Name</th>
							<td><cfinput type="text" name="last" /></td>
						</tr>
						<tr>
							<th>First Name</th>
							<td><cfinput type="text" name="first" /></td>
						</tr>
						<tr>
							<th>Title</th>
							<td><cfinput type="text" name="title" /></td>
						</tr>
						<tr>
							<th>Department</th>
							<td><cfinput type="text" name="department" /></td>
						</tr>
						<tr>
							<td>&nbsp;</td>
							<td><cfinput type="submit" class="btn" onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'" name="search" value="Search"/></td>
						</tr> 
					</table>
				</cfform>
			</div>
			
			<div id="main" class="sideBarLeft">
				
				<cfif isdefined("ldapUsers")>
				<table>
					<tr>
						<th>Last Name</th>
						<th>First Name</th>
						<th>Department</th>
						<th>Title</th>
						<th>Phone</th>
					</tr>
					<cfoutput query="ldapUsers">
					<tr onmousedown="location.href = 'edit.cfm?cn=#URLEncodedFormat(cn)#';"
						onmouseover="this.style.cursor = 'hand';"
						class="#IIF(CurrentRow mod 2 eq 0, DE('odd'), DE('even'))#">
						<td>#sn#</td>
						<td>#givenName#</td>
						<td>#department#</td>
						<td>#title#</td>
						<td>#telephoneNumber#</td>
					</tr>
					</cfoutput>
				</table>
				</cfif>
			</div>
		</div>
	</body>
</html>